//用户模型

const { Model, DataTypes } = require("sequelize");

class User extends Model {}

User.init(
  {
    id: {
      type: DataTypes.INTEGER.UNSIGNED,
      primaryKey: true,
      autoIncrement: true,
      allowNull: false,
      comment: "表id",
    },

    userId: {
      type: DataTypes.STRING(36),
      unique: true,
      allowNull: false,
      defaultValue: "",
      comment: "用户id",
    },

    email: {
      type: DataTypes.STRING(40),
      allowNull: false,
      unique: true,
      defaultValue: "",
      comment: "邮箱",
    },

    password: {
      type: DataTypes.STRING(32),
      allowNull: false,
      defaultValue: "",
      comment: "密码",
    },

    // userImg: {
    //   type: DataTypes.STRING(100),
    //   allowNull: false,
    //   defaultValue:
    //     "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fsecure.meetupstatic.com%2Fphotos%2Fevent%2F6%2Fe%2Fb%2F600_471601771.jpeg&refer=http%3A%2F%2Fsecure.meetupstatic.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1657709019&t=fbb7d58789839d7d2d777db64d7072f1",
    //   comment: "用户头像",
    // },

    phone: {
      type: DataTypes.STRING(11),
      allowNull: true,
      defaultValue: null,
      comment: "手机号",
    },

    nickName: {
      type: DataTypes.STRING(20),
      allowNull: true,
      defaultValue: null,
      comment: "昵称",
    },

    sex: {
      type: DataTypes.BOOLEAN,
      allowNull: false,
      defaultValue: 2,
      comment: "性别:0男1女2未知",
    },
  },
  {
    sequelize,
    tableName: "user",
  }
);

User.sync({
  force: false,
});

module.exports = User;
